import * as constants from '../Constants'
import { get, GET_SCM_Primary_LIST, GET_Primary_BY_ID } from '../../service/api'


export interface GetPrimaryList {
  type: constants.GetPrimaryList
  payload: Promise<any>
}

export interface GetPrimaryList_PENDING {
  type: constants.GetPrimaryList_PENDING
  payload: Promise<any>
}

export interface GetPrimaryList_FULFILLED {
  type: constants.GetPrimaryList_FULFILLED
  payload: any
}

export interface GetPrimaryList_PAGE {
  type: constants.GetPrimaryList_PAGE
  payload: any
}

export interface RECORD_Primary {
  type: constants.RECORD_Primary
  payload: Promise<any>
}

export interface RECORD_Primary_FULFILLED {
  type: constants.RECORD_Primary_FULFILLED
  payload: Promise<any>
}

export type PrimaryAction = GetPrimaryList | 
  GetPrimaryList_FULFILLED | 
  GetPrimaryList_PENDING | 
  GetPrimaryList_PAGE |
  RECORD_Primary |
  RECORD_Primary_FULFILLED


export function getPrimaryList(param: any): GetPrimaryList {
  return {
    type: constants.GetPrimaryList,
    payload: get(GET_SCM_Primary_LIST, param)
  }
}
export function recordPrimary(param: any): RECORD_Primary {
  return {
    type: constants.RECORD_Primary,
    payload: get(GET_Primary_BY_ID, param)
  }
}
export function page(page: any): GetPrimaryList_PAGE {
  return {
    type: constants.GetPrimaryList_PAGE,
    payload: page
  }
}